﻿using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using XNAFight.Engine.Inputs;

namespace XNAFight.Scene.Core
{
    public class EventArgs<T> : EventArgs
    {
        public EventArgs(T value)
        {
            m_value = value;
        }

        private T m_value;

        public T Value
        {
            get { return m_value; }
        }
    }

    /// Représente un élément de menu
    public abstract class MenuItem
    {
        #region CHAMPS

        // Position du texte à l'écran
        public Vector2 position;

        #endregion

        #region EVENTS

        // Pour la validation de l'élément
        public event EventHandler Selected;
        public event EventHandler<EventArgs<ControlerSelection>> SelectedBy;

        // Pour la propagation de la validation de l'élément
        internal void OnItemSelected()
        {
            if (Selected != null)
                Selected(this, new EventArgs());
        }
        internal void OnItemSelected(ControlerSelection _selection)
        {
            if (SelectedBy != null)
                SelectedBy(this, new EventArgs<ControlerSelection>(_selection));
        }

        #endregion

        #region INITIALISATION

        public MenuItem (Vector2 _pos)
        {
            position = _pos;
        }

        #endregion

        #region UPDATE / DRAW

        public abstract void Update(GameTime _gameTime, bool _is_selected);
        public abstract void Update(GameTime _gameTime, List<int> _player_ids);
        public abstract void Draw(GameTime _gameTime, bool _is_selected);
        public abstract void Draw(GameTime _gameTime, List<int> _player_ids);

        #endregion
    }
}
